package com.joy.redisstudy;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.Connection;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.concurrent.TimeoutException;

public class RabbitMqProducer {

    public static void main(String[] args) {
        // 连接工厂
//        CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
//        connectionFactory.setHost("127.0.0.1");
//        connectionFactory.setUsername("guest");
//        connectionFactory.setPassword("guest");
//        connectionFactory.setVirtualHost("/");
//        // 创建连接
//        Connection connection = connectionFactory.createConnection();
//        Channel channel = connection.createChannel(true);
//        try {
//            channel.queueDeclare("TEST_MQ", false, false, false, null);
//            channel.txSelect();
//            channel.basicPublish("", "TEST_MQ", null, "测试消息".getBytes());
//            channel.txCommit();
//            channel.close();
//            connection.close();
//        } catch (IOException e) {
//            try {
//                channel.txRollback();
//            } catch (IOException ex) {
//                throw new RuntimeException(ex);
//            }
//            throw new RuntimeException(e);
//        } catch (TimeoutException e) {
//            throw new RuntimeException(e);
//        }



//        double xx = (new BigDecimal(281 / 2 * 22.0).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue() - 1328-435);
        double xx = (new BigDecimal(281).divide(new BigDecimal(2)).multiply(new BigDecimal(22)).doubleValue() - 1328-435);
        System.out.println(xx);
//        connection.
    }
}
